<?php //strip
/**
 * Class that representing single reservation.
 * 
 * @package odReservationsWpPlugin
 * @subpackage odReservationsWpPlugin_Models
 * @author Ondrej Donek <ondrejd@gmail.com>
 */
class odReservationsWpPlugin_Models_Reservation_Item
{
  protected $mId = 0;
  protected $mMemberId = 0;
  protected $mMemberNum = '';
  protected $mMemberName = '';
  protected $mPlaygroundId = 0;
  protected $mPlaygroundName = '';
  protected $mPlaymates = 0;
  protected $mStart = null;
  protected $mCancelled = null;
  protected $mCancelledWhen = null;
  protected $mNote = '';

  /**
   * Constructor of class odReservationsWpPlugin_Models_Reservation_Item.
   * 
   * @param array $aValues Should be array like one provided by model class.
   * @return void
   */
  public function __construct($aValues = null)
  {
    if(is_array($aValues)) {
      $this->mId = ((array_key_exists('ID', $aValues)) ? $aValues['ID'] : 0);
      $this->mMemberId = ((array_key_exists('member_ID', $aValues)) ? $aValues['member_ID'] : 0);
      $this->mMemberNum = ((array_key_exists('member_num', $aValues)) ? $aValues['member_num'] : '');
      $this->mMemberName = ((array_key_exists('member_name', $aValues)) ? $aValues['member_name'] : '');
      $this->mPlaygroundId = ((array_key_exists('playground_ID', $aValues)) ? $aValues['playground_ID'] : '');
      $this->mPlaygroundName = ((array_key_exists('playground_name', $aValues)) ? $aValues['playground_name'] : '');
      $this->mPlaymates = ((array_key_exists('playmates', $aValues)) ? $aValues['playmates'] : 0);
      $this->mStart = ((array_key_exists('start', $aValues)) ? $aValues['start'] : date('Y-m-d h:i:s'));
      $this->mCancelled = ((array_key_exists('cancelled', $aValues)) ? $aValues['cancelled'] : null);
      $this->mCancelledWhen = ((array_key_exists('cancelled_when', $aValues)) ? $aValues['cancelled_when'] : null);
      $this->mNote = ((array_key_exists('note', $aValues)) ? $aValues['note'] : '');
    }
  }
  
  /**
   * Getter for class properties.
   * 
   * @param string $aKey
   * @return mixed
   * @throws Exception Whenever <code>$aKey</code> was not recognized.
   */
  public function __get($aKey) 
  {
    switch($aKey) {
      case 'ID': return $this->_getId(); break;
      case 'member_ID': return $this->_getMemberId(); break;
      case 'member_num': return $this->_getMemberNum(); break;
      case 'member_name': return $this->_getMemberName(); break;
      case 'playground_ID': return $this->_getPlaygroundId(); break;
      case 'playground_name': return $this->_getPlaygroundName(); break;
      case 'playmates': return $this->_getPlaymates(); break;
      case 'start': return $this->_getStart(); break;
      case 'cancelled': return $this->_getCancelled(); break;
      case 'cancelled_when': return $this->_getCancelledWhen(); break;
      case 'note': return $this->_getNote(); break;
      default:
        throw new Exception('Unrecognized property key!');
        break;
    }
  }
  
  protected function _getId() { return $this->mId; }
  protected function _getMemberId() { return $this->mMemberId; }
  protected function _getMemberNum() { return $this->mMemberNum; }
  protected function _getMemberName() { return $this->mMemberName; }
  protected function _getPlaygroundId() { return $this->mPlaygroundId; }
  protected function _getPlaygroundName() { return $this->mPlaygroundName; }
  protected function _getPlaymates() { return $this->mPlaymates; }
  protected function _getStart() { return $this->mStart; }
  protected function _getCancelled() { return $this->mCancelled; }
  protected function _getCancelledWhen() { return $this->mCancelledWhen; }
  protected function _getNote() { return $this->mNote; }
  
  /**
   * Setter for class properties.
   * 
   * @param string $aKey
   * @param mixed $aValue
   * @return void
   * @throw Exception Whenever <code>$aKey</code> was not recognized.
   */
  public function __set($aKey, $aValue)
  {
    switch($aKey) {
      case 'ID': return $this->_setId($aValue); break;
      case 'member_ID': return $this->_setMemberId($aValue); break;
      case 'playground_ID': return $this->_setPlaygroundId($aValue); break;
      case 'playmates': return $this->_setPlaymates($aValue); break;
      case 'start': return $this->_setStart($aValue); break;
      case 'cancelled': return $this->_setCancelled($aValue); break;
      case 'cancelled_when': return $this->_setCancelledWhen($aValue); break;
      case 'note': return $this->_setNote($aValue); break;
      case 'member_num':
      case 'member_name':
      case 'playground_name':
        throw new Exception('Value of selected property is readonly!');
        break;
      default:
        throw new Exception('Unrecognized property key!');
        break;
    }
  }
  
  protected function _setId($aValue) { $this->mId = $aValue; }
  protected function _setMemberId($aValue) { $this->mMemberId = $aValue; }
  protected function _setPlaygroundId($aValue) { $this->mPlaygroundId = $aValue; }
  protected function _setPlaymates($aValue) { $this->mPlaymates = $aValue; }
  protected function _setStart($aValue) { $this->mStart = $aValue; }
  protected function _setCancelled($aValue) { $this->mCancelled = $aValue; }
  protected function _setCancelledWhen($aValue) { $this->mCancelledWhen = $aValue; }
  protected function _setNote($aValue) { $this->mNote = $aValue; }
  
} // End of odReservationsWpPlugin_Models_Reservation_Item
